package com.financial.business.integral.service.impl;

import com.financial.business.integral.constants.FinancialRefundIntegralEnumConstants;
import com.financial.business.integral.service.FinancialIntegralRefundService;
import com.financial.business.integral.service.yd.FinancialYDIntergralRefundService;
import com.financial.business.integral.utils.JsonUtils;
import com.financial.business.integral.utils.apiresult.ApiResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * @Author WANGNING
 * @Email wyn20140226@aliyun.com
 * @Description //积分退款业务处理
 * @Date 2019/12/4 10:29
 */
@Service
public class FinancialIntegralRefundServiceImpl implements FinancialIntegralRefundService {

    public static final Logger logger = LoggerFactory.getLogger(FinancialIntegralRefundServiceImpl.class);

    @Autowired
    private FinancialYDIntergralRefundService financialYDIntergralRefundService;


    @Override
    public ApiResult refund(String requestParam) {
        logger.info("FinancialIntegralRefundServiceImpl.refund()-----积分退款获取到的json信息为：" + requestParam);
        /*解析参数信息判断支付渠道*/
        Map<String, Object> map = JsonUtils.jsonToMap(requestParam);
        String payChannelNo = (String) map.get("pay_channel_no");
        logger.info("FinancialIntegralRefundServiceImpl.refund()-----积分退款支付渠道为：" + payChannelNo);
        ApiResult apiResult = ApiResult.failure(FinancialRefundIntegralEnumConstants.ENUM_RETURNMESSAGE_FAIL);
        /*判断支付渠道*/
        if (payChannelNo.equalsIgnoreCase(FinancialRefundIntegralEnumConstants.ENUM_PAYCHANNEL_YDINTEGRAL)) {
            /*优店平台积分支付*/
            apiResult = financialYDIntergralRefundService.refund(requestParam);
        }
        return apiResult;
    }
}
